package com.ocean.controller.news;

import com.ocean.dto.AuthorQueryDto;
import com.ocean.entity.news.Author;
import com.ocean.service.news.AuthorService;
import com.ocean.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/api/author/")
public class AuthorController {
    @Autowired
    private AuthorService service;

    @PostMapping("save.do")
    public R save(@RequestBody Author obj){
        return service.save(obj);
    }
    @PostMapping("update.do")
    public R update(@RequestBody Author obj){
        return service.update(obj);
    }
    @GetMapping("del.do")
    public R delete(int id){
        return service.delete(id);
    }
    @GetMapping("page.do")
    public R page(int page,int size){
        return service.queryPage(page, size);
    }
    @GetMapping("pagewhere.do")
    public R page(AuthorQueryDto dto){
        return service.queryPageWhere(dto);
    }

    @PostMapping("import.do")
    public R importData(MultipartFile file){
        return service.importData(file);
    }
    @GetMapping("export.do")
    public void exportData(HttpServletResponse response){
        service.exportData(response);
    }

    @GetMapping("echarts.do")
    public R echarts(){
        return service.queryEcharts();
    }
}
